/**
 * @file led_drv_pwm.c
 * @author Jason Wen (embediot@163.com)
 * @brief 使用 MCU PWM引脚驱动LED
 * @version 0.1
 * @date 2024-06-07
 * 
 * @copyright EmbedIoT Studio Copyright (c) 2024
 * 
 */

#include "led_drv_pwm.h"
#include "stddef.h"


led_drv_pwm_t led_drv_pwm;

//初始化MCU的PWM引脚接口
static void mcu_pwm_init(void)
{
    //在这里初始化MCU的PWM外设接口，比如初始化STM32的定时器PWM
}

static int _init(void *_this)
{
    int ret = 0;

    mcu_pwm_init();

    return ret;
}

static int _turn_on(void *_this, led_id_t id)
{
    int ret = 0;

    //调用PWM接口，设置占空比

    return ret;
}

static int _turn_off(void *_this, led_id_t id)
{
    int ret = 0;

    //调用PWM接口，设置占空比

    return ret;
}

static int _set_brightness(void *_this, led_id_t id, unsigned char level)
{
    int ret = 0;

    //调用PWM接口，设置占空比
    
    return ret;
}

static int _set_color(void *_this, led_id_t id, rgbcw_t *color)
{
    int ret = 0;

    return ret;
}

static int _toggle(void *_this, led_id_t id)
{
    int ret = 0;

    return ret;
}


led_drv_pwm_t *led_drv_pwm_create(void)
{
    //初始化驱动函数接口
    led_drv_pwm.drv.init = _init;
    led_drv_pwm.drv.turn_on = _turn_on;
    led_drv_pwm.drv.turn_off = _turn_off;
    led_drv_pwm.drv.toggle = _toggle;
    led_drv_pwm.drv.set_brightness = _set_brightness;
    led_drv_pwm.drv.set_color = NULL;

    led_drv_pwm.drv.led_count = LED_MAX_NUM;
    
    return &led_drv_pwm;
}


